﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlServerCe;
using PolePositionMobileUtilityGeneral;

namespace PolePositionMobileUtilityData
{
    public class DBaseLookup
    {
        public static DataTable SelectAll(string tableName, string tableColumnName, string tableColumnId)
        {

            DataTable _Dt = new DataTable();
            SqlCeConnection _Con = null;
            SqlCeDataAdapter _Da = null;
            StringBuilder _sql = new StringBuilder();
            try
            {
                _Con = Utils.GetConnection();
                #region Query
                _sql.AppendLine("SELECT * ");
                //_sql.AppendLine(tableColumnName + "," + tableColumnId);
                _sql.AppendLine(" FROM ");
                _sql.AppendLine(tableName);
                _sql.AppendLine(" ORDER BY "+tableColumnId);
                #endregion Query
                _Da = new SqlCeDataAdapter(_sql.ToString(), _Con);
                _Da.SelectCommand.CommandType = CommandType.Text;
                _Da.Fill(_Dt);
                return _Dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (_Con != null)
                {
                    _Con.Close();
                }
            }
        }
    }
}
